package com.xqc.common.utils;

import com.xqc.common.constants.ComConstants;

import java.io.Serializable;

public class XqcWebResult<T> implements Serializable{
    private boolean success = true;
    private String code;
    private String message;
    private T data;

    public XqcWebResult(boolean success, String code, String message, T data) {
        this.success = success;
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public XqcWebResult() {
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public static<T> XqcWebResult<T> success(T t){
        return new XqcWebResult(true, ComConstants.SUC,"success",t);
    }

    public static<T> XqcWebResult<T> fail(T t){
        return new XqcWebResult(false,ComConstants.FAIL,"fail",t);
    }

    public static<T> XqcWebResult<T> fail(){
        return new XqcWebResult(false,ComConstants.FAIL,"fail",null);
    }

}
